<?php if (!defined('BASEPATH')) exit('No direct script access allowed');


class Adminhtml extends Admin_Controller {
	function __construct()
	{
		parent::__construct();
		$this->admin_navigation->parent_active('users');
	}
	function index(){
		$columns = array(
						array(
							'name' => 'ID',
							'type' => 'id',
							'index'=>'id',
							'sort_column'=>'desc'
							),
						array(
							'name'=>'Tên đăng nhập',
							'type'=>'text',
							'filter'=>'username',
							'index'=>'username',
						),
						array(
							'name'=>'Ngày tạo',
							'type'=>'date',
							'filter'=>'created',
							'index'=>'created',
						),
						array(
							'name'=>'Trạng thái',
							'type'=>'publish',
							'filter'=>'is_active',
							'index'=>'is_active',
							'options'=>array(
											 '0'=>'Tắt',
											 '1'=>'Bật'
											)
						),
						array(
							'name'=>'Ngày hết vip',
							'type'=>'date',
							'filter'=>'day_out_vip',
							'index'=>'day_out_vip',
						)
		);
		$this->grid->columns($columns);
		$this->grid->datasource('users_model','getUsers');
		$this->grid->base_url(admin_url('users/'));
		$this->grid->title('Thành viên');
		//$this->grid->addbutton('Thêm mới',admin_url('reports/add'),'add');
		$this->grid->initialize(TRUE);
		$this->grid->action('Delete','delete');
		$this->load->model('users_model');
		$total_rows = $this->users_model->getCount($this->grid->get_unlimited_parameters());
		$this->grid->total_rows($total_rows);
		$this->load->view('admin/users');
	}
	function publish(){
		$id = $this->input->post('id');
		$publish = $this->input->post('publish');
		$this->load->model('users_model');
		$this->users_model->Publish($id,$publish);
		$data = '1';
		echo $this->jsonservice->encode($data);
	}
}